﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Mortgage.DDL
{
    public class CashHoldingUI
    {
        public decimal CashWaiting { set; get; }
        public decimal CashTrading { set; get; }
        public decimal CashBlocking { set; get; }
        private decimal _cash;
        public decimal Cash 
        {
            set
            {
                _cash = value;
            }
            get 
            { 
                return CashWaiting + CashTrading + CashBlocking; 
            }
        }
        public decimal PreLoan { set; get; }
        public decimal StockTradingValue { set; get; }
        public decimal StockWaitingValue { set; get; }
        public decimal StockTradingLoanValue { set; get; }
        public decimal StockWaitingLoanValue { set; get; }
        public decimal AccumulateLoanValue { set; get; }
        private decimal _mortgageallow;
        public decimal MortgageAllow 
        {
            set
            {
                _mortgageallow = value;
            }
            get 
            { 
                return LoanLimit - AccumulateLoanValue; 
            }
        }
        private decimal _stockratio;
        public decimal LoanRatioOnStockValue
        {
            set
            {
                _stockratio = value;
            }
            get 
            { 
                return StockValue.Equals(0) ? 0 : (AccumulateLoanValue / StockValue) * 100; 
            }
        }
        private decimal _totalratio;
        public decimal LoanRatioOnTotalValue
        {
            set
            {
                _totalratio = value;
            }
            get 
            { 
                return TotalValue.Equals(0) ? 0 : (AccumulateLoanValue / TotalValue) * 100; 
            }
        }
        private decimal _stockalloratio;
        public decimal LoanRatioOnStocksAllow
        {
            set
            {
                _stockalloratio = value;
            }
            get 
            { 
                return MortgageAllow.Equals(0) ? 0 : (AccumulateLoanValue / MortgageAllow) * 100; 
            }
        }
        private decimal _loanlimit;
        public decimal LoanLimit
        {
            set
            {
                _loanlimit = value;
            }
            get 
            { 
                return StockTradingLoanValue + StockWaitingLoanValue; 
            }
        }
        private decimal _stockvalue;
        public decimal StockValue
        {
            set
            {
                _stockvalue = value;
            }
            get 
            { 
                return StockTradingValue + StockWaitingValue; 
            }
        }
        private decimal _totalvalue;
        public decimal TotalValue
        {
            set
            {
                _totalvalue = value;
            }
            get 
            { 
                return Cash + StockValue; 
            }
        }

        public CashHoldingUI() { }
        public CashHoldingUI(decimal trading, decimal waiting, decimal blocking, decimal preloan, decimal accumulateloan, decimal mortgageallow, decimal stocktradingvalue, decimal stockwaitingvalue)
        {
            CashTrading = trading;
            CashWaiting = waiting;
            CashBlocking = blocking;
            PreLoan = preloan;
            AccumulateLoanValue = accumulateloan;
            StockTradingValue = stocktradingvalue;
            StockWaitingValue = stockwaitingvalue;
        }
    }
}
